import os

import xlrd

"""
filename:文件名
index:需要从哪一行进行读取
注意：确保excel中数据的数据都是字符串
"""


def read_excel(filename, index):
    filepath = os.path.dirname(os.path.dirname(__file__)) + os.sep + "data" + os.sep + filename
    xr = xlrd.open_workbook_xls(filepath)
    arr = []
    for a in range(index, xr.sheet_by_index(0).nrows):  # 获取索引
        arr.append(tuple(xr.sheet_by_index(0).row_values(a)))
    return arr


if __name__ == "__main__":
    result = read_excel("login_data.xls", 1)
    print(result)
    # data = xlrd.open_workbook_xls("../data/login_data.xls")
    # print(data.sheet_by_index(0).nrows)
